package com.coderman.infosys.auth.infrast.gatawayimpl;

import java.util.List;

import com.coderman.infosys.auth.infrast.cache.SystemCache;
import com.coderman.infosys.plat.auth.common.page.PageBO;
import com.coderman.infosys.auth.domain.bo.system.MenuBO;
import com.coderman.infosys.auth.domain.bo.system.SystemBO;
import com.coderman.infosys.auth.domain.bo.system.ModuleBO;
import com.coderman.infosys.auth.domain.gataway.SystemModuleQueryGataWay;
import com.coderman.infosys.auth.infrast.dao.dataobject.ModuleDO;
import com.coderman.infosys.auth.infrast.dao.mapper.ModuleMapper;
import com.coderman.infosys.auth.infrast.dao.dataobject.MenuDO;
import com.coderman.infosys.auth.infrast.dataconvert.MenuConvert;
import com.coderman.infosys.auth.infrast.dataconvert.ModuleConvert;
import com.coderman.infosys.auth.infrast.dataconvert.SystemConvert;
import com.coderman.infosys.auth.infrast.dao.mapper.SystemMapper;
import com.coderman.infosys.auth.infrast.dao.dataobject.SystemDO;
import com.coderman.infosys.auth.infrast.dao.mapper.MenuMapper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * @Description:接口实现类
 * @Author：
 * @CreateTime：2022-01-02 15:27:38
 * @version v1.0
 */
@Service
public class SystemModuleQueryGataWayImpl  implements SystemModuleQueryGataWay{

	private  Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private SystemMapper systemMapper;

    @Autowired
    private ModuleMapper moduleMapper;

    @Autowired
    private MenuMapper menuMapper;

    @Autowired
    private SystemCache systemCache;


    @Override
	public List<SystemBO> querySystemPage(PageBO pageBO){
        List<SystemDO> systemDOList = systemMapper.getPageList(pageBO);
        Integer totalCount = systemMapper.getTotalCount(pageBO);
        pageBO.setTotalRows(totalCount);
        return SystemConvert.INSTANCE.doList2boList(systemDOList);
    }

    @Override
	public List<ModuleBO> queryModulePage(PageBO pageBO){
        List<ModuleDO> moduleDOList = moduleMapper.getPageList(pageBO);
        return ModuleConvert.INSTANCE.doList2boList(moduleDOList);
    }

    @Override
    public List<MenuBO> queryMenuPage(PageBO pageBO) {
        List<MenuDO> menuDOList = menuMapper.getPageList(pageBO);
        return MenuConvert.INSTANCE.doList2boList(menuDOList);
    }


    @Override
	public List<SystemBO> queryByCondition(String search){
        List<SystemDO> systemDOList = systemMapper.queryByCondition(search);
        return SystemConvert.INSTANCE.doList2boList(systemDOList);
    }

    @Override
    public List<SystemBO> queryAll() {
        List<SystemDO> systemDOList = systemMapper.getAll();
        return SystemConvert.INSTANCE.doList2boList(systemDOList);
    }


    @Override
	public SystemBO getSystemByCode(String systemCode){
        SystemDO systemDO = systemMapper.getBySystemCode(systemCode);
        return  SystemConvert.INSTANCE.do2bo(systemDO);
    }

    @Override
    public SystemBO getSystemByCache(String systemCode) {
        return systemCache.getSystem(systemCode);
    }

    @Override
	public ModuleBO getModuleByCode(String moduleCode){
        ModuleDO moduleDO = moduleMapper.getByModuleCode(moduleCode);
        return ModuleConvert.INSTANCE.do2bo(moduleDO);
    }

    @Override
	public MenuBO getMenu(String menuCode){
        MenuDO menuDO = menuMapper.getByMenuCode(menuCode);
        return MenuConvert.INSTANCE.do2bo(menuDO);
    }

    @Override
	public SystemBO getSystemByName(String systemName){
        SystemDO systemDO = systemMapper.getByName(systemName);
        return SystemConvert.INSTANCE.do2bo(systemDO);
    }

    @Override
    public List<ModuleBO> getModuleBySystemCode(String systemCode) {
        List<ModuleDO> moduleDOList = moduleMapper.getBySystemCode(systemCode);
        return ModuleConvert.INSTANCE.doList2boList(moduleDOList);
    }

}